package org.syg.generator.util;

/**
 * @author ps
 */
public class UnderToCamel {


    /**
     * <p>说明:获取java类名</p>
     * @param table  表名
     * @return String
     */
    public static String getClassName(String table) {
        table=changeToJavaFiled(table);
        StringBuilder sbuilder = new StringBuilder();
        char[] cs = table.toCharArray();
        cs[0] -= 32;
        sbuilder.append(String.valueOf(cs));
        return sbuilder.toString();
    }

    /**
     * <p>说明:获取字段名，把"_"后面字母变大写</p>
     * @param field  字段名
     * @return String
     */
    public static String changeToJavaFiled(String field) {
        field = field.toLowerCase();
        String[] fields = field.split("_");
        StringBuilder sb = new StringBuilder(fields[0]);
        for (int i = 1; i < fields.length; i++) {
            char[] cs = fields[i].toCharArray();
            cs[0] -= 32;
            sb.append(String.valueOf(cs));
        }
        return sb.toString();
    }
}
